drop table if exists jms_dm.dm_waybill_false_taking_summary_dt;
CREATE TABLE if not exists jms_dm.dm_waybill_false_taking_summary_dt(
    dt                                    date     NOT NULL COMMENT '分区日期'
    ,taking_date                          date     NOT NULL COMMENT '揽收日期'
    ,receive_network_code                 varchar(255)      COMMENT '收件网点编码'
    ,order_source_code                    varchar(255)      comment '订单来源'
    ,taking_user_code                     varchar(255)      comment '揽收业务员code'
    ,customer_code                        varchar(255)      comment '客户code'
    ,receive_network_name                 varchar(255)      COMMENT '收件网点名称'
    ,receive_fran_code                    varchar(255)      COMMENT '收件加盟商编码'
    ,receive_fran_name                    varchar(255)      COMMENT '收件加盟商名称'
    ,receive_agent_code                   varchar(255)      COMMENT '收件代理区编码'
    ,receive_agent_name                   varchar(255)      COMMENT '收件代理区名称'
    ,receive_virt_agent_code              varchar(255)      comment '收件虚拟代理区编码'
    ,receive_virt_agent_name              varchar(255)      comment '收件虚拟代理区名称'
    ,taking_user_name                     varchar(255)      comment '揽收业务员名称'
    ,customer_name                        varchar(255)      comment '客户名称'
    ,receive_network_taking_cnt           bigint            comment '网点揽收数量'
    ,receive_network_send_cnt             bigint            comment '网点发件数量'
    ,collect_arr_cnt                      bigint            comment '集散到件数量'
    ,center_arr_cnt                       bigint            comment '中心到件数量'
    ,receive_network_false_taking_cnt     bigint            comment '收件网点虚假揽收票数'
    ,receive_network_should_hand_in_cnt   bigint            comment '收件网点应交件票数'
    ,interrupted_taking_cnt               bigint            comment '截单后揽收数'
    ,false_taking_no_send_cnt             bigint            comment '虚假揽收未发件数'
    ,false_taking_no_hand_in_cnt          bigint            comment '虚假揽收未到件数'
    ,taking_duration_hour                 decimal(10, 2)    comment '揽收时长(只看虚假揽收)'
)
ENGINE=olap
DUPLICATE KEY(dt, taking_date, receive_network_code,  order_source_code)
comment '虚假揽收日报-网点汇总'
PARTITION BY RANGE (dt) (
    START ("2023-06-20") END ("2023-07-10") EVERY (INTERVAL 1 day)
)
DISTRIBUTED BY HASH(receive_network_code) BUCKETS 3
PROPERTIES (
    "replication_num" = "3",
    "dynamic_partition.enable" = "true",
    "dynamic_partition.time_unit" = "DAY",
    "dynamic_partition.start" = "-185",
    "dynamic_partition.end" = "3",
    "dynamic_partition.prefix" = "p",
    "dynamic_partition.buckets" = "3",
    "in_memory" = "false",
    "storage_format" = "V2"
);